﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using Earthwatchers.Models.Portable;
using Earthwatchers.Data;


namespace Earthwatchers.Services.Security.MembershipProviders
{
    public class EarthwatchersMembershipProvider : IMembershipProvider
    {
        private readonly string connectionString;

        public EarthwatchersMembershipProvider(string connectionString)
        {
            this.connectionString = connectionString;
        }

        public bool ValidateUser(string username, string password)
        {
            var isValid = false;
            var credentials = CredentialsRepository.GetCredentials(connectionString, username);
            isValid = PasswordChecker.CheckPassword(password, credentials.Prefix, credentials.Hash);
            return isValid;
        }
    }
}